package top.catchcat.blogs.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.catchcat.blogs.dao.userIfo.User;
import top.catchcat.blogs.mapper.BlogMapper;
import top.catchcat.blogs.mapper.UserMapper;
import top.catchcat.blogs.service.LoginService;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private BlogMapper blogMapper;

    @Override
    public void githubLogin(User user) {
        User mapperUserByAccountId = userMapper.getUserByAccountId(user.getAccount_id());
        if (mapperUserByAccountId == null)
            userMapper.insertUser(user);
        else userMapper.updateUser(user);
    }

    @Override
    public User getUserByToken(String token) {
        return userMapper.getUserByToken(token);
    }

}
